<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>求质数</title>
</head>

<body>

</body>

</html>
<script>
    var a = prompt("请输入数值");
    if (a >= 2) {
        function method(a) {
            for (var b = 2; b < a; b++) {
                if (a % b == 0) {
                    return alert("是合数");
                }
            }
            return alert("是质数");
        }
        method(a);
    }else{
        alert("既非质数也非合数");
    }
</script>